package com.silence.gmall.product.rpc;

import com.silence.gmall.annotations.Log;
import com.silence.gmall.base.Result;
import com.silence.gmall.product.service.CategoryService;
import com.silence.gmall.web.vo.res.CategoryResVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author silence
 * @Description 一级分类表控制器
 * @Date 2025-08-17 16:28:16
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/inner/product")
public class CategoryRpcController {

    /**
     * CategoryService 的注入
     */
    private final CategoryService categoryService;

    /**
     * 数据库查询所有分类
     *
     * @return 所有分类树形结构
     */
    @GetMapping("/category/tree")
    @Log(interfaceName = "数据库查询所有分类")
    public Result<List<CategoryResVo>> getCategoryTree() {
        return Result.build(categoryService.getCategoryTree());
    }

}